package com.hamster.crmpre.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hamster.crmpre.pojo.ChatRecord;
import com.hamster.crmpre.pojo.dto.ImageList;
import com.hamster.crmpre.pojo.dto.ImageUrl;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 聊天记录截图的 mapper
 * @author Tarry
 * @create 2020/2/13 13:52
 */
@Repository
@Mapper
public interface ChatRecordMapper extends BaseMapper<ChatRecord> {

    /**
     * 根据id标记删除
     * @param id
     */
    @Update("update chat_record set del = 1 where id = #{id}")
    void deleteRecord(@Param("id") String id);

    /**
     * 查询聊天记录
     * @param customerId
     * @param employeeId
     * @return
     */
    @Select("select * from chat_record where customer_id=#{customerId} and employee_id=#{employeeId} and del=0 order by create_time desc")
    @Results({
            @Result(column = "id",property = "id"),
            @Result(column = "image_url",property = "url"),
            @Result(column = "create_time",property = "createTime")
    })
    List<ImageUrl> listRecord(@Param("customerId") String customerId, @Param("employeeId") String employeeId);
}
